home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_37_soundlevel.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  3.0 KB  |  73 lines

  1. property downState, boundingsprite, Slider, background, upstate
  2.  
  3. on getPropertyDescriptionList
  4.   if the currentSpriteNum = 0 then
  5.     set memdefault to 0
  6.   else
  7.     set memref to the member of sprite the currentSpriteNum
  8.     set castLibNum to the castLibNum of memref
  9.     set memdefault to member (the memberNum of member memref + 1) of castLib castLibNum
  10.   end if
  11.   set p_list to [#downState: [#comment: "Pict for Down:", #format: #bitmap, #default: memdefault], #background: [#comment: "Slider Background Sprite:", #format: #integer, #default: the currentSpriteNum + 1], #boundingsprite: [#comment: "Bounding Box Sprite:", #format: #integer, #default: the currentSpriteNum + 2], #Slider: [#comment: "Slider Knob Sprite:", #format: #integer, #default: the currentSpriteNum + 3]]
  12.   return p_list
  13. end
  14.  
  15. on getBehaviorDescription
  16.   return "Pops up a slider to set the system volume." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Down Member - the picture of the button when pressed." & RETURN & "ΓÇó Slider Background Sprite - the slider background sprite." & RETURN & "ΓÇó Bounding Box Sprite - the bounding box sprite, make invisible rect." & RETURN & "ΓÇó Slider Knob Sprite - the slider knob sprite."
  17. end
  18.  
  19. on getAssocMembers
  20.   set myPropList to [downState]
  21.   return myPropList
  22. end
  23.  
  24. on beginSprite me
  25.   set upstate to the member of sprite the spriteNum of me
  26. end
  27.  
  28. on mouseDown me
  29.   set the member of sprite the spriteNum of me to member downState
  30.   set soundRangeCast to the number of member the castNum of sprite boundingsprite
  31.   set soundHeight to the height of cast soundRangeCast
  32.   set the loc of sprite background to point((the left of sprite boundingsprite + the right of sprite boundingsprite) / 2, (the top of sprite boundingsprite + the bottom of sprite boundingsprite) / 2)
  33.   set the loc of sprite Slider to the loc of sprite boundingsprite
  34.   set gOutLevel to 7 - the soundLevel
  35.   set the locV of sprite Slider to (gOutLevel * (soundHeight / 7)) + the top of sprite boundingsprite
  36.   updateStage()
  37.   set the constraint of sprite Slider to boundingsprite
  38.   repeat while the stillDown
  39.     if rollOver(background) then
  40.       set the locV of sprite Slider to the mouseV
  41.       set gOutLevel to (the mouseV - the top of sprite boundingsprite + 1) / (soundHeight / 7)
  42.       updateStage()
  43.     end if
  44.   end repeat
  45.   set the member of sprite the spriteNum of me to upstate
  46.   updateStage()
  47.   if gOutLevel < 0 then
  48.     set gOutLevel to 0
  49.   end if
  50.   if gOutLevel > 7 then
  51.     set gOutLevel to 7
  52.   end if
  53.   set the soundLevel to 7 - gOutLevel
  54.   if soundBusy(2) = 0 then
  55.     beep()
  56.   end if
  57.   set the loc of sprite background to point(1000, 1000)
  58.   set the loc of sprite boundingsprite to point(1000, 1000)
  59.   set the loc of sprite Slider to point(1000, 1000)
  60.   puppetSprite(the spriteNum of me, 0)
  61.   puppetSprite(background, 0)
  62.   puppetSprite(boundingsprite, 0)
  63.   puppetSprite(Slider, 0)
  64. end
  65.  
  66. on endSprite me
  67.   puppetSprite(the spriteNum of me, 0)
  68.   puppetSprite(background, 0)
  69.   puppetSprite(boundingsprite, 0)
  70.   puppetSprite(Slider, 0)
  71.   set the constraint of sprite Slider to 0
  72. end
  73.